package com.qf.day03.practice;

import java.util.Arrays;
import java.util.Scanner;

/**
 * 循环录入5个人人的成绩，求最大成绩、最小成绩、平均成绩
 */
public class practice01 {
    public static void main(String[] args) {
        int[]arr =new int[5];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            System.out.print("输入"+(i+1)+"个学生的成绩");
            arr[i]=sc.nextInt();
        }
        int max =arr[0],min=arr[0],sum=0;
        double avg =0;
        for (int j = 0; j < arr.length; j++) {
            if(max<arr[j]){
                max=arr[j];
            }
            if(min>arr[j]){
                min=arr[j];
            }
            sum+=arr[j];
            avg=(double)sum/5.0;
        }
        System.out.println("最高分"+max);
        System.out.println("最低分"+min);
        System.out.println("平均分"+avg);
        System.out.println("总分"+sum);
        Arrays.sort(arr);
        System.out.println("从低到高排序：");
        for (int i = 0; i < 5; i++) {
            System.out.println(arr[i]+" ");
        }
    }
}
